/**
 * Callback method for when form is shown.
 *
 * @param {Boolean} firstShow form is shown first time after load
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"D197FD52-16E7-48CB-86EC-A066FA1636FE"}
 * @AllowToRunInFind
 */
function onShow(firstShow, event) {

	// Establecemos la valueList con los valores de los menús padre
	/** @type {JSFoundSet<db:/pigeon_board/adm_t900_menus>} */
	var fs_adm_t900_menus = databaseManager.getFoundSet(scopes.adm_t900_menus.$DATA_SOURCE);
	fs_adm_t900_menus.loadAllRecords();
	if (fs_adm_t900_menus.find()){
		fs_adm_t900_menus.adm_t900_menus_padre_id = '^';
		fs_adm_t900_menus.search();
	}
	
	var sql_query = "SELECT s_descripcion, adm_t900_menus_id " + 
								"FROM adm_t900_menus " + 
								"WHERE adm_t900_menus_padre_id is null";
	/** @type {JSDataSet} */
	var dataset = databaseManager.getDataSetByQuery(globals.$NOMBRE_SERVIDOR, sql_query, null, -1);
	application.setValueListItems("custom_vlst_adm_t900_menus_padre", dataset);
}

/**
 * @properties={typeid:24,uuid:"BBA8C9BF-BF4C-40EA-AD22-F6010B96B0BC"}
 */
function aceptar_siguiente_antes(){
	
	// Salvar datos
	globals.saveEdits_foundset(forms[controller.getName()].foundset);
	// Datos Aceptar / Siguiente
	var _adm_t900_menus_padre_id = adm_t900_menus_padre_id;
	var _adm_t900_aplicaciones_id = adm_t900_aplicaciones_id;
	// Nuevo Registro
	foundset.newRecord();
	adm_t900_menus_padre_id = _adm_t900_menus_padre_id;
	adm_t900_aplicaciones_id = _adm_t900_aplicaciones_id;
}

/**
 * Handle changed data.
 *
 * @param {String} oldValue old value
 * @param {String} newValue new value
 * @param {JSEvent} event the event that triggered the action
 *
 * @returns {Boolean}
 *
 * @private
 *
 * @properties={typeid:24,uuid:"630729A0-9FDA-4C93-A59F-1606E9A932B2"}
 */
function onDataChange(oldValue, newValue, event) {
	
	elements.lbl_s_icono.imageURL = "media:///" + newValue;
	return true;
}
